<?php
namespace app\admin\controller;
class Adminuser extends Base
{
  //欢迎页面
    public function index(){
      $this->fetch();
    }
   //编辑
    public function editself($id=''){
        if(is_post()){
            $rule = [
                'username'=>'require',
                'domain'=>'require',
                'pic'=>'require',
                'password'=>'min:6',
            ];
            $msg = [
              'password.min' => '密码至少6位',
              'pic.require' => '请上传网站LOGO',
            ];
            $d = $this->post;
            check($rule,$msg,$d);
            unset($d['file']);
            if(!empty($d['password'])){
                $d['password'] = com_password($d['password']);
            }else{
                unset($d['password']);
            }
            $this->db->update('admin_user',$d);
            m('Attachment','xcom')->imgSure('admin_user',$d['id'],$d);
            cookie('js_msg','修改成功');
            cookie('js_function','f5');
            return suc();
        }
        $this->fetch(['info'=>$this->userinfo]);
    }
}
